#define _CRT_SECURE_NO_WARNINGS

//
// Created by 79816 on 2023/1/19.
//

#include <string.h>
#include "common.h"
#include <stdio.h>


void hash_xor_int(unsigned char* hash, int num, unsigned char* xor_result)
{
    int xor_temp;
    int part_result;
    memcpy(&xor_temp,hash,INT_SIZE);
    part_result=num^xor_temp;
    memcpy(xor_result,&part_result,INT_SIZE);
    memcpy(xor_result+INT_SIZE,hash+INT_SIZE,KEY_LENGTH_BYTES-INT_SIZE);
}

void print_hex(unsigned char* data, int length)
{
    printf("\n");
    for(int i=0;i<length;++i)
    {
        printf("%02x",data[i]);
    }
    printf("\n");
}

int arrayToStr(unsigned char* buf, unsigned int buflen, char* out)
{
    char strBuf[33] = { 0 };
    char pbuf[32];
    int i;
    for (i = 0; i < buflen; i++)
    {
        sprintf(pbuf, "%02X", buf[i]);
        strncat(strBuf, pbuf, 2);
    }
    strncpy(out, strBuf, buflen * 2);
    printf("out = %s\n", out);
    return buflen * 2;
}
